<template>
	<view class="pageBox">
		<header-nav :headeBgImg="false" headerTitle="查看地图" :needMessage="true"></header-nav>
		<view class="mapbox"
			:style="'height:calc(100vh - 88rpx - ' + navTop + 'px);'">
			<!-- <view class="placeholder" style="padding-top:{{navTop}}px;"></view> -->
			<map id="map" scale="13" :longitude="longitude" :latitude="latitude" :markers="markers"></map>
			<private_tip :privateShow="privateb"></private_tip>
		</view>
	</view>
</template>

<script>
	import headerNav from '../../components/public_header/public_header';
	// pages/map/map.js
	const app = getApp();
	var _this;
	export default {
		components: {
			headerNav
		},
		data() {
			return {
				navTop: app.globalData.navTop,
				imgPath: app.globalData.imgPath,
				imgVersion: app.globalData.imgVersion,
				longitude: 120.738527,
				latitude: 31.199367,
				address: '',
				markers: [],
				privateb:false,
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			_this = this;
			if(app.globalData.wxprivate==-1){
				app.watchG('wxprivate',function(value){
					_this.wxprivate=value;
					if(value){ //弹出弹窗
						_this.privateb=true;
					}else{
						_this.onload(options);
					}
				})
			}else{
				if (app.globalData.wxprivate) { //弹出弹窗
					_this.privateb = true;
				} else {
					_this.onload(options);
				}
			}
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			onload(options){
				if (options.lng && options.lat) {
					_this.longitude = options.lng
					_this.latitude = options.lat
					_this.address = options.address
				}
				if (!options.markers) {
					var iconPath = _this.imgPath + '/info/posi.png?v=' + _this.imgVersion;
					_this.markers = [{
						id: 1,
						longitude: options.lng,
						latitude: options.lat,
						title: options.address,
						iconPath: iconPath,
						width: 30,
						height: 30
					}]
				}
			},
		}
	};
</script>
<style>
	@import './map.css';
</style>